package com.lw.obj;

import com.lw.GameWin;
import com.lw.utils.GameUtils;
import lombok.NoArgsConstructor;

import java.awt.*;
import java.util.Random;

/**
 * 食物对象
 */
@NoArgsConstructor
public class FoodObj extends GameObj{

    Random r = new Random();

    public FoodObj(Image img, int x, int y, GameWin gameWin) {
        super(img, x, y, gameWin);
    }

    /**
     * 获取食物
     * @return
     */
    public FoodObj getFood(){
        int x = r.nextInt(20)*30; // 0,30,60,90.....570
        int y = (r.nextInt(19)+1)*30; //30,60,90.....570  要去掉标题的大小
        return new FoodObj(GameUtils.foodImg,x,y,gameWin);
    }

    @Override
    public void paintSelf(Graphics g) {
        super.paintSelf(g);
    }
}
